package com.aaa.sys.service.impl;

import com.aaa.sys.entity.DictType;
import com.aaa.sys.mapper.DictTypeMapper;
import com.aaa.sys.service.DictTypeService;
import com.aaa.sys.vo.DictTypeVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 字典类型表 服务实现类
 * </p>
 *
 * @author ykq
 * @since 2020-12-08
 */
@Service
public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> implements DictTypeService {

    @Override
    public Page<DictType> findDictTypeAll(Integer page, Integer limit, DictTypeVo dictTypeVo) {
        QueryWrapper<DictType> wrapper=new QueryWrapper<>();
        String condition = dictTypeVo.getCondition();
        String status = dictTypeVo.getStatus();
        if (StringUtils.isNotEmpty(status)){
            wrapper.eq("status",status);
        }
        if(StringUtils.isNotEmpty(condition)){
            wrapper.and(w -> w.like("name",condition).or().like("code",condition));
        }
        Page<DictType> page1=new Page<>(page,limit);
        this.baseMapper.selectPage(page1,wrapper);
        return page1;
    }


}
